home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsrc.lha / ixemul / library / ixemul.h < prev    next >
C/C++ Source or Header  |  1996-03-13  |  7KB  |  293 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  ixemul.h,v 1.1.1.1 1994/04/04 04:29:38 amiga Exp
  20.  *
  21.  *  ixemul.h,v
  22.  * Revision 1.1.1.1  1994/04/04  04:29:38  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.4  1993/11/05  22:14:40  mwild
  26.  *  changes there, here...
  27.  *
  28.  *  Revision 1.3  1992/10/20  16:32:33  mwild
  29.  *  *** empty log message ***
  30.  *
  31.  *  Revision 1.2  1992/07/04  19:25:26  mwild
  32.  *  change __rwport to reflect the current state of the (now global) async port
  33.  *
  34.  * Revision 1.1  1992/05/14  20:36:14  mwild
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39. #ifndef _IXEMUL_H_
  40. #define _IXEMUL_H_
  41.  
  42. #ifdef START
  43.  
  44. /* definitions for the assembler startup file */
  45.  
  46. /* when I've REALLY lots of free time, I'll rewrite header files, but now... */
  47.  
  48. /* amazingly works, contains only defines ;-)) */
  49. #include <exec/alerts.h>
  50.  
  51. #define _LVOOpenLibrary        -0x228
  52. #define _LVOCloseLibrary     -0x19e
  53. #define _LVOAlert        -0x6c
  54. #define _LVOFreeMem        -0xd2
  55. #define _LVORemove        -0xfc
  56.  
  57. #define RTC_MATCHWORD    0x4afc
  58. #define RTF_AUTOINIT    (1<<7)
  59.  
  60. #define LIBF_CHANGED    (1<<1)
  61. #define LIBF_SUMUSED    (1<<2)
  62. /* seems there is an assembler bug in expression evaluation here.. */
  63. #define LIBF_CHANGED_SUMUSED 0x6
  64. #define LIBF_DELEXP    (1<<3)
  65. #define LIBB_DELEXP    3
  66.  
  67. #define LN_TYPE        8
  68. #define LN_NAME        10
  69. #define NT_LIBRARY    9
  70. #define MP_FLAGS    14
  71. #define PA_IGNORE    2
  72.  
  73. #define LIST_SIZEOF    14
  74.  
  75. #define THISTASK    276
  76.  
  77. #define INITBYTE(field,val)    .word 0xe000; .word (field); .byte (val); .byte 0
  78. #define INITWORD(field,val)    .word 0xd000; .word (field); .word (val)
  79. #define INITLONG(field,val)    .word 0xc000; .word (field); .long (val)
  80.  
  81. /*
  82.  * our library base.. 
  83.  */
  84.  
  85. /* struct library */
  86. #define    IXBASE_NODE    0
  87. #define IXBASE_FLAGS    14
  88. #define IXBASE_NEGSIZE    16
  89. #define IXBASE_POSSIZE    18
  90. #define IXBASE_VERSION    20
  91. #define IXBASE_REVISION    22
  92. #define IXBASE_IDSTRING    24
  93. #define IXBASE_SUM    28
  94. #define IXBASE_OPENCNT    32
  95. #define IXBASE_LIBRARY    34    /* size of library */
  96.  
  97. /* custom part */
  98. #define IXBASE_MYFLAGS        (IXBASE_LIBRARY + 0)
  99. #define IXBASE_SEGLIST        (IXBASE_MYFLAGS + 2)
  100. #define IXBASE_C_PRIVATE    (IXBASE_SEGLIST + 4)
  101.  
  102. #else  /* C-part */
  103.  
  104. #include <exec/types.h>
  105. #include <exec/libraries.h>
  106. #include <exec/execbase.h>
  107. #include <exec/ports.h>
  108. #include <libraries/dosextens.h>
  109.  
  110. #include <sys/types.h>
  111.  
  112. #ifdef KERNEL
  113. #define _INTERNAL_FILE
  114. #endif
  115.  
  116. #include <sys/file.h>
  117. #include <sys/param.h>
  118. #include <packets.h>
  119. #include <sys/syscall.h>
  120. #include <signal.h>
  121. #include <user.h>
  122.  
  123. #include <errno.h>
  124.  
  125. /* ix_flags defines */
  126.  
  127.    #define ix_create_enforcer_hit             0x00002000
  128.    #define ix_do_not_flush_library             0x00001000
  129.    #define ix_allow_amiga_wildcard             0x00000800
  130.    #define ix_no_insert_disk_requester             0x00000400
  131.    #define ix_unix_pattern_matching_case_sensitive    0x00000200
  132. /* #define ix_unix_pattern_matching             0x00000100 obsolete */
  133. /* #define ix_no_ces_then_open_console             0x00000080 obsolete */
  134.    #define ix_ignore_global_env             0x00000040
  135. /* #define ix_disable_fibcache                 0x00000020 obsolete */
  136. /* #define ix_translate_dots                 0x00000010 obsolete */
  137.    #define ix_watch_stack                 0x00000008
  138. /* #define ix_force_translation             0x00000004 obsolete */
  139. /* #define ix_translate_symlinks             0x00000002 obsolete */
  140.    #define ix_translate_slash                0x00000001
  141.  
  142. /* ix_network_type enum */
  143.  
  144. enum
  145. {
  146.   IX_NETWORK_AUTO,
  147.   IX_NETWORK_NONE,
  148.   IX_NETWORK_AS225,
  149.   IX_NETWORK_AMITCP,
  150.   IX_NETWORK_END_OF_ENUM
  151. };
  152.  
  153. /* configure this to the number of hash queues you like, 
  154.  * use a prime number !!
  155.  */
  156. #define IX_NUM_SLEEP_QUEUES    31
  157.  
  158. struct ixemul_base {
  159.   struct Library        ix_lib;
  160.  
  161. /* don't use the remainder of the library base. The contents can change
  162.    without warning in the future. */
  163. #ifdef KERNEL
  164.   unsigned char            ix_myflags;    /* used by start.s */
  165.   unsigned char            ix_pad;
  166.   BPTR                ix_seg_list;    /* used by start.s */
  167.  
  168.   /* the global file table with current size */
  169.   struct file            *ix_file_tab;
  170.   struct file            *ix_fileNFILE;
  171.   struct file            *ix_lastf;
  172.  
  173.   /* size of start of red zone from bottom of stack */
  174.   int                ix_red_zone_size;
  175.  
  176.   struct SignalSemaphore    ix_semaph;
  177.   int                ix_membuf_limit;
  178.   
  179.   /* multiplier for id_BytesPerBlock to get to st_blksize, default 64 */
  180.   int                ix_fs_buf_factor;
  181.  
  182.   unsigned long            ix_flags;
  183.  
  184.   struct MinList        ix_sleep_queues [IX_NUM_SLEEP_QUEUES];
  185.  
  186.   struct MinList        ix_socket_list;
  187.   long                      ix_gmt_offset;
  188.   int                ix_network_type;
  189.  
  190.   int                ix_next_free_port;
  191.   struct Task                   *task_switcher;
  192. #endif
  193. };
  194.  
  195.  
  196. /* this is the only prototype of library functions, that are really used inside
  197.  * the library. (So a user can patch a function, and the library will use
  198.  * the new entry, and not a hard compiled address */
  199. #define syscall(vec, args...) \
  200.   ({register int (*_sc)()=(void *)(&((char *)ixemulbase)[-((vec)+4)*6]); _sc(args);})
  201.  
  202. /* Structure to pass ixemul.library settings to/from the library base */
  203. struct ix_settings {
  204.   int version;
  205.   int revision;
  206.   unsigned long flags;
  207.   int membuf_limit;
  208.   int red_zone_size;
  209.   int fs_buf_factor;
  210.   int network_type;
  211. };
  212.  
  213. /* Environment name of ixemul settings */
  214. #define IX_ENV_SETTINGS "ixemul.prefs"
  215.  
  216. void ix_set_gmt_offset(long offset);
  217. long ix_get_gmt_offset(void);
  218. struct ix_settings *ix_get_default_settings(void);
  219. struct ix_settings *ix_get_settings(void);
  220. void ix_set_settings(struct ix_settings *settings);
  221.  
  222. #ifdef KERNEL
  223.  
  224. #include <ixprotos.h>
  225.  
  226. extern struct ixemul_base *ixemulbase;
  227.  
  228. #define ix (*ixemulbase)
  229. #define u (*(struct user *)(SysBase->ThisTask->tc_TrapData))
  230. #define getuser(p)   ((struct user *)((p)->pr_Task.tc_TrapData))
  231.  
  232. static inline u_int get_usp (void) 
  233.   u_int res;
  234.  
  235.   asm volatile ("movel    usp,%0" : "=a" (res));
  236.   return res;
  237. }
  238.  
  239. static inline void set_usp (u_int new_usp)
  240. {
  241.   asm volatile ("movel  %0,usp" : /* no output */ : "a" (new_usp));
  242. }
  243.  
  244. static inline u_int get_sp (void) 
  245.   u_int res;
  246.  
  247.   asm volatile ("movel    sp,%0" : "=a" (res));
  248.   return res;
  249. }
  250.  
  251. static inline void set_sp (u_int new_sp)
  252. {
  253.   asm volatile ("movel  %0,sp" : /* no output */ : "a" (new_sp));
  254. }
  255.  
  256. static inline u_short get_sr (void) 
  257.   u_short res;
  258.  
  259.   asm volatile ("movew    sr,%0" : "=g" (res));
  260.   return res;
  261. }
  262.  
  263. static inline u_int get_fp (void) 
  264.   u_int res;
  265.  
  266.   asm volatile ("movel    a5,%0" : "=g" (res));
  267.   return res;
  268. }
  269.  
  270. #define PRIVATE
  271. extern struct ExecBase *SysBase;
  272. #include <inline/exec.h>
  273. #undef PRIVATE
  274.  
  275. extern struct DosLibrary *DOSBase;
  276. #include <inline/dos.h>
  277.  
  278. #define errno (* u.u_errno)
  279.  
  280. extern struct MsgPort *ix_async_mp;
  281. #define __rwport (ix_async_mp)
  282. #define __srwport (u.u_sync_mp)
  283.  
  284. #endif /* KERNEL */
  285.  
  286. #endif /* START */
  287.  
  288. #endif /* _IXEMUL_H */
  289.